-module(rtps_domain_sup).

-behaviour(supervisor).

%% API
-export([start_link/3]).

%% Supervisor callbacks
-export([init/1]).

%%====================================================================
%% API functions
%%====================================================================

start_link(Id, Reg, Opts) ->
    supervisor:start_link(?MODULE, [Id, Reg, Opts]).

%%====================================================================
%% Supervisor callbacks
%%====================================================================

%% @private
init([Id, Reg, Opts]) ->
    Opts1 = [{domain_id, Id} | Opts],
    {ok, {#{strategy => one_for_all},
	  [#{id => registry,
	     start => {rtps_reg, start_link, []},
	     restart => permanent,
	     type => worker},
	   #{id => transports,
	     start => {rtps_transport_sup, start_link, []},
	     restart => permanent,
	     type => supervisor},
	   #{id => participants,
	     start => {rtps_ofo_sup, start_link, []},
	     restart => permanent,
	     type => supervisor},
	   #{id => domain,
	     start => {rtps_domain, start_link, [self(), Id, Reg, Opts1]},
	     restart => permanent,
	     type => worker}
	   ]}}.

%%====================================================================
%% Internal functions
%%====================================================================

